# -*- encoding: utf-8 -*-


import mod.server.extraServerApi as serverApi
import lobbyGame.netgameApi as lobbyGameApi
import apolloCommon.commonNetgameApi as commonNetgameApi
import nuoyanlib_server as nyl
from nuoyanlib_server import CompFactory, LvComp
from .common.constants import *


class T31CommonServerSystem(nyl.NuoyanServerSystem):
    def __init__(self, namespace, systemName):
        super(T31CommonServerSystem, self).__init__(namespace, systemName)

    # ========================================= Engine Event Callback ==================================================

    def ServerChatEvent(self, args):
        playerId = args['playerId']
        message = args['message']
        # hub回城指令
        if message == "hub":
            args['cancel'] = True
            if commonNetgameApi.GetServerType() == "lobby":
                LvComp.Msg.NotifyOneMessage(playerId, "你已在主城。")
            else:
                def callback(isSuc, reasonCode, reasonMsg):
                    if not isSuc:
                        LvComp.Msg.NotifyOneMessage(playerId, "§4回城失败： " + reasonMsg)
                lobbyGameApi.TransferToOtherServer(playerId, "lobby", "", callback)

    # ========================================= Custom Event Callback ==================================================

    # =========================================== Basic Function =======================================================














